package com.lc.test.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @description: some desc
 * @author: LChuang
 * @date: 2023/9/4 15:28
 */
@Data
public class ApiResult implements Serializable {

    private static final long serialVersionUID = -1L;
    
    private Integer code;
    
    private String message;
    
    private Object data;

    private ApiResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private ApiResult(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ApiResult success(Integer code, String message, Object data) {
        return new ApiResult(code, message, data);
    }

    public static ApiResult success(Integer code, String message) {
        return success(code, message, (Object)null);
    }

    public static ApiResult success(String message, Object data) {
        return success(200, message, data);
    }

    public static ApiResult success(Object data) {
        return success(200, "success", data);
    }

    public static ApiResult success() {
        return new ApiResult(200, "success");
    }

    public static ApiResult fail(int code, String message) {
        return new ApiResult(code, message);
    }

    public static ApiResult fail(String message) {
        return fail(500, message);
    }

    public static ApiResult fail() {
        return fail(500, "系统繁忙,请稍后再试");
    }

    public static ApiResult paramMissing() {
        return fail(400, "参数缺失,请检查");
    }
    
}
